<template>
  <el-container>
    <el-header>
      <div class="left-panel">
        <el-button v-auth="'setting:api:sync'" type="primary" icon="el-icon-Refresh" @click="sync">同步接口</el-button>
      </div>
    </el-header>
    <el-main class="nopadding">
      <SailorTable ref="tableRef" :apiObj="Apis.api_setting.api.list" row-key="uuid" stripe>
        <el-table-column label="唯一标识" prop="uuid" min-width="230" align="center"></el-table-column>
        <el-table-column label="创建时间" prop="createdAt" width="200" align="center"></el-table-column>
        <el-table-column label="接口描述" prop="apiDescription" min-width="200" show-overflow-tooltip
                         align="center"></el-table-column>
        <el-table-column label="请求方式" prop="apiMethod" min-width="100" align="center"></el-table-column>
        <el-table-column label="接口路径" prop="apiPath" min-width="200" show-overflow-tooltip
                         align="center"></el-table-column>
        <el-table-column label="所属分组" prop="apiGroup" min-width="150" align="center"></el-table-column>
      </SailorTable>
    </el-main>
  </el-container>
</template>

<script setup name="apis">
import Apis from '@/api'
import {ElMessage} from "element-plus";
import {ref} from "vue";
import SailorTable from "@/components/SailorTable/index.vue";

let tableRef = ref()

// 从内存同步接口
const sync = async () => {
  let res = await Apis.api_setting.api.sync.get()
  if (res.code === 0) {
    ElMessage.success("同步成功")
    tableRef.value.refresh()
  } else {
    ElMessage.error(res.message)
  }
}
</script>

<style>
</style>
